package com.easy.controller;

import com.easy.service.OssCleanupService;
import com.easy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/oss")
public class OssCleanupController {
    
    @Autowired
    private OssCleanupService ossCleanupService;
    
    /**
     * 手动触发清理OSS未使用图片的任务
     * @return 操作结果
     */
    @PostMapping("/cleanup")
    public Result cleanupUnusedImages() {
        try {
            ossCleanupService.cleanupUnusedImages();
            return Result.success("OSS未使用图片清理任务执行完成");
        } catch (Exception e) {
            return Result.fail(500, "清理任务执行失败: " + e.getMessage());
        }
    }
}